Skip to content

feat(permissions): refresh snapshots from live invalidations - #23

Merged
lusu007 merged 5 commits into
mainfrom
feat/live-snapshot-invalidation
Jul 29, 2026
Merged

lusu007 merged 5 commits into
mainfrom
feat/live-snapshot-invalidation

Conversation

@lusu007

@lusu007 lusu007 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • consume the strict permissions.snapshot.invalidated Core NATS event in the shared runtime module
  • coalesce concurrent invalidations and refresh only online players through the authoritative REST snapshot endpoint
  • wire optional, non-blocking invalidation subscribers into Velocity and Minestom with race-safe lifecycle ownership
  • retain login, manual refresh, and periodic polling as fallback paths

Safety

  • only schema version 1 with the exact schemaVersion and playerId fields is accepted
  • configured token files fail closed and are reread for reconnect authentication
  • malformed events and transport failures use stable, non-sensitive log reasons
  • unavailable NATS never prevents the Minecraft runtime from starting

Verification

  • ./gradlew test
  • ./gradlew spotlessApply
  • ./gradlew build
  • focused codec, subscriber, coordinator, Velocity lifecycle, and Minestom lifecycle regressions
  • generated Velocity JAR contains velocity-plugin.json
  • Minestom public no-argument and Clock constructors remain available

@lusu007
lusu007 marked this pull request as ready for review July 29, 2026 14:34
@lusu007
lusu007 merged commit da630b9 into main Jul 29, 2026
3 checks passed
@lusu007
lusu007 deleted the feat/live-snapshot-invalidation branch July 29, 2026 14:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc066b4bd0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

private val inFlight = ConcurrentHashMap.newKeySet<UUID>()

fun invalidate(playerId: UUID) {
if (!isOnline(playerId) || !inFlight.add(playerId)) return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve invalidations received during an active refresh

When another invalidation for the same player arrives after the first refresh has started, this early return discards it permanently. If the first REST request captured policy state before the second mutation but completes afterward, the coordinator installs that older snapshot and schedules no follow-up fetch; both Velocity and Minestom can therefore retain a stale grant or revocation until the periodic sweep reaches refreshAfter. Record a pending invalidation and rerun the refresh after the in-flight request completes rather than dropping the event.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant